package pivotIndex;

import java.util.Arrays;

public class Solution {
    public int pivotIndex(int[] nums) {
        int half = Arrays.stream(nums).sum()/2;
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if(sum+nums[i] == half){
                return i;
            }
            sum+=nums[i];
        }
        return -1;
    }
}
